import { createRouter, createWebHistory } from 'vue-router'

//导入组件
import LoginVue from '@/views/Login.vue'

import ExamListVue from '@/views/exam/ExamList.vue'
import UserAvatarVue from '@/views/user/UserAvatar.vue'
import UserInfoVue from '@/views/user/UserInfo.vue'
import UserResetPasswordVue from '@/views/user/UserResetPassword.vue'
import TeacherLayoutVue from '@/views/user/teacher/TeacherLayout.vue'
import AdminLayoutVue from '@/views/user/admin/AdminLayout.vue'
import TeacherManageVue from '@/views/user/admin/TeacherManage.vue'
import StudentLayoutVue from '@/views/user/student/StudentLayout.vue'
import MyExamsVue from '@/views/user/student/MyExams.vue'
import ExamAddStudentsVue from '@/views/exam/ExamAddStudents.vue'
import SpaceVue from '@/views/Space.vue'

//定义路由关系
const routes = [

    { path: '/login', component: LoginVue },
    { path: '/', component: SpaceVue, redirect: '/admin' },
    {
        path: '/student', component: StudentLayoutVue,
        children: [
            { path: 'myExams', component: MyExamsVue },
            { path: 'user/info', component: UserInfoVue },
            { path: 'user/avatar', component: UserAvatarVue },
            { path: 'user/resetPassword', component: UserResetPasswordVue }

        ]
    },
    {
        path: '/teacher', component: TeacherLayoutVue,
        children: [
            { path: 'exam/addStudents', component: ExamAddStudentsVue },
            { path: 'home', component: ExamListVue },
            { path: 'user/info', component: UserInfoVue },
            { path: 'user/avatar', component: UserAvatarVue },
            { path: 'user/resetPassword', component: UserResetPasswordVue }
        ]
    },

    {
        path: '/admin', component: AdminLayoutVue,
        children: [
            { path: 'teacherManage', component: TeacherManageVue },

        ]
    },

]

//创建路由器
const router = createRouter({
    history: createWebHistory(),
    routes: routes
})

//导出路由
export default router
